/*
 *  Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 *  This source code is licensed under the MIT license found in the LICENSE
 *  file in the root directory of this source tree.
 *
 */

/*
 *  THIS FILE IS AUTOGENERATED. DO NOT MODIFY IT; ALL CHANGES WILL BE LOST IN
 *  VAIN.
 *
 *  @generated
 */
#include "mcrouter/lib/carbon/test/gen/CarbonThriftTestMessages.h"

#include "mcrouter/lib/carbon/test/gen/gen-cpp2/CarbonThriftTest_types.h"

namespace carbon {
namespace test {
namespace thrift {

void TestUnionThrift::deserialize(carbon::CarbonProtocolReader& reader) {
  reader.readStructBegin();
  while (true) {
    const auto pr = reader.readFieldHeader();
    const auto fieldType = pr.first;
    const auto fieldId = pr.second;

    if (fieldType == carbon::FieldType::Stop) {
      break;
    }

    switch (fieldId) {
      case 1: {
        reader.readRawInto(set_a());
        break;
      }
      case 2: {
        reader.readRawInto(set_b());
        break;
      }
      case 3: {
        reader.readRawInto(set_c());
        break;
      }
      default: {
        reader.skip(fieldType);
        break;
      }
    }
  }
  reader.readStructEnd();
}

void TinyStruct::deserialize(carbon::CarbonProtocolReader& reader) {
  reader.readStructBegin();
  while (true) {
    const auto pr = reader.readFieldHeader();
    const auto fieldType = pr.first;
    const auto fieldId = pr.second;

    if (fieldType == carbon::FieldType::Stop) {
      break;
    }

    switch (fieldId) {
      case 1: {
        reader.readField(foo_ref(), fieldType);
        break;
      }
      default: {
        reader.skip(fieldType);
        break;
      }
    }
  }
  reader.readStructEnd();
}

void MyBaseStruct::deserialize(carbon::CarbonProtocolReader& reader) {
  reader.readStructBegin();
  while (true) {
    const auto pr = reader.readFieldHeader();
    const auto fieldType = pr.first;
    const auto fieldId = pr.second;

    if (fieldType == carbon::FieldType::Stop) {
      break;
    }

    switch (fieldId) {
      case 1: {
        reader.readField(baseInt64Member_ref(), fieldType);
        break;
      }
      default: {
        reader.skip(fieldType);
        break;
      }
    }
  }
  reader.readStructEnd();
}

void MySimpleStruct::deserialize(carbon::CarbonProtocolReader& reader) {
  reader.readStructBegin();
  while (true) {
    const auto pr = reader.readFieldHeader();
    const auto fieldType = pr.first;
    const auto fieldId = pr.second;

    if (fieldType == carbon::FieldType::Stop) {
      break;
    }

    switch (fieldId) {
      case -1: {
        reader.readField(myBaseStruct, fieldType);
        break;
      }
      case 1: {
        reader.readField(int32Member_ref(), fieldType);
        break;
      }
      case 2: {
        reader.readField(stringMember_ref(), fieldType);
        break;
      }
      case 3: {
        reader.readField(enumMember_ref(), fieldType);
        break;
      }
      case 4: {
        reader.readField(vectorMember_ref(), fieldType);
        break;
      }
      default: {
        reader.skip(fieldType);
        break;
      }
    }
  }
  reader.readStructEnd();
}

void ThriftTestRequest::deserialize(carbon::CarbonProtocolReader& reader) {
  reader.readStructBegin();
  while (true) {
    const auto pr = reader.readFieldHeader();
    const auto fieldType = pr.first;
    const auto fieldId = pr.second;

    if (fieldType == carbon::FieldType::Stop) {
      break;
    }

    switch (fieldId) {
      case -2: {
        reader.readField(tinyStruct, fieldType);
        break;
      }
      case -1: {
        reader.readField(base, fieldType);
        break;
      }
      case 1: {
        reader.readField(key_ref(), fieldType);
        break;
      }
      case 2: {
        reader.readField(testBool_ref(), fieldType);
        break;
      }
      case 3: {
        reader.readField(testInt8_ref(), fieldType);
        break;
      }
      default: {
        reader.skip(fieldType);
        break;
      }
    }
  }
  reader.readStructEnd();
}

void ThriftTestReply::deserialize(carbon::CarbonProtocolReader& reader) {
  reader.readStructBegin();
  while (true) {
    const auto pr = reader.readFieldHeader();
    const auto fieldType = pr.first;
    const auto fieldId = pr.second;

    if (fieldType == carbon::FieldType::Stop) {
      break;
    }

    switch (fieldId) {
      case 1: {
        reader.readField(result_ref(), fieldType);
        break;
      }
      case 2: {
        reader.readField(message_ref(), fieldType);
        break;
      }
      default: {
        reader.skip(fieldType);
        break;
      }
    }
  }
  reader.readStructEnd();
}

void DummyThriftRequest::deserialize(carbon::CarbonProtocolReader& reader) {
  reader.readStructBegin();
  while (true) {
    const auto pr = reader.readFieldHeader();
    const auto fieldType = pr.first;
    const auto fieldId = pr.second;

    if (fieldType == carbon::FieldType::Stop) {
      break;
    }

    switch (fieldId) {
      case 1: {
        reader.readField(key_ref(), fieldType);
        break;
      }
      case 2: {
        reader.readField(testBool_ref(), fieldType);
        break;
      }
      case 3: {
        reader.readField(testInt8_ref(), fieldType);
        break;
      }
      case 4: {
        reader.readField(testInt16_ref(), fieldType);
        break;
      }
      case 5: {
        reader.readField(testInt32_ref(), fieldType);
        break;
      }
      case 6: {
        reader.readField(testInt64_ref(), fieldType);
        break;
      }
      case 7: {
        reader.readField(testUInt8_ref(), fieldType);
        break;
      }
      case 8: {
        reader.readField(testUInt16_ref(), fieldType);
        break;
      }
      case 9: {
        reader.readField(testUInt32_ref(), fieldType);
        break;
      }
      case 10: {
        reader.readField(testUInt64_ref(), fieldType);
        break;
      }
      case 11: {
        reader.readField(testFloat_ref(), fieldType);
        break;
      }
      case 12: {
        reader.readField(testDouble_ref(), fieldType);
        break;
      }
      case 13: {
        reader.readField(testShortString_ref(), fieldType);
        break;
      }
      case 14: {
        reader.readField(testLongString_ref(), fieldType);
        break;
      }
      case 15: {
        reader.readField(testIobuf_ref(), fieldType);
        break;
      }
      case 16: {
        reader.readField(testList_ref(), fieldType);
        break;
      }
      case 17: {
        reader.readField(testOptionalKeywordBool_ref(), fieldType);
        break;
      }
      case 18: {
        reader.readField(testOptionalKeywordString_ref(), fieldType);
        break;
      }
      case 19: {
        reader.readField(testOptionalKeywordIobuf_ref(), fieldType);
        break;
      }
      default: {
        reader.skip(fieldType);
        break;
      }
    }
  }
  reader.readStructEnd();
}

void DummyThriftReply::deserialize(carbon::CarbonProtocolReader& reader) {
  reader.readStructBegin();
  while (true) {
    const auto pr = reader.readFieldHeader();
    const auto fieldType = pr.first;
    const auto fieldId = pr.second;

    if (fieldType == carbon::FieldType::Stop) {
      break;
    }

    switch (fieldId) {
      case 1: {
        reader.readField(result_ref(), fieldType);
        break;
      }
      case 2: {
        reader.readField(message_ref(), fieldType);
        break;
      }
      default: {
        reader.skip(fieldType);
        break;
      }
    }
  }
  reader.readStructEnd();
}

void CustomRequest::deserialize(carbon::CarbonProtocolReader& reader) {
  reader.readStructBegin();
  while (true) {
    const auto pr = reader.readFieldHeader();
    const auto fieldType = pr.first;
    const auto fieldId = pr.second;

    if (fieldType == carbon::FieldType::Stop) {
      break;
    }

    switch (fieldId) {
      case 1: {
        reader.readField(key_ref(), fieldType);
        break;
      }
      case 2: {
        reader.readField(testInt8_ref(), fieldType);
        break;
      }
      case 3: {
        reader.readField(timestamp_ref(), fieldType);
        break;
      }
      case 4: {
        reader.readField(customAdapterTypeI64_ref(), fieldType);
        break;
      }
      case 5: {
        reader.readField(customAdapterTypeBinary_ref(), fieldType);
        break;
      }
      default: {
        reader.skip(fieldType);
        break;
      }
    }
  }
  reader.readStructEnd();
}

void CustomReply::deserialize(carbon::CarbonProtocolReader& reader) {
  reader.readStructBegin();
  while (true) {
    const auto pr = reader.readFieldHeader();
    const auto fieldType = pr.first;
    const auto fieldId = pr.second;

    if (fieldType == carbon::FieldType::Stop) {
      break;
    }

    switch (fieldId) {
      case 1: {
        reader.readField(result_ref(), fieldType);
        break;
      }
      case 2: {
        reader.readField(valInt32_ref(), fieldType);
        break;
      }
      default: {
        reader.skip(fieldType);
        break;
      }
    }
  }
  reader.readStructEnd();
}
} // namespace thrift
} // namespace test
} // namespace carbon
